﻿@using db = System.Data.Entity.Infrastructure;
@using si.caha.Model;
@using si.caha.Repository;

@{
    var disabledAttribute = "";
    if (IsPost)
    {
		var dataBase = Database.Open("db");
        var categoryId = dataBase.QueryValue("SELECT CategoryId FROM categories WHERE LOWER(Title) = LOWER(@0)", "Test");
		dataBase.Execute("INSERT INTO items (CategoryId, DateAdded, Title, Description, Price) VALUES (@0, @1, 'Rome Crail', 'Ful dobr bord jada jada jada', 200.0)", 
                        categoryId, System.DateTime.Now);
		dataBase.Execute("INSERT INTO items (CategoryId, DateAdded, Title, Description, Price) VALUES (@0, @1, 'Smith Gogglez', 'Ful dobre špegle jada jada jada', 99.9)", 
                        categoryId, System.DateTime.Now);
        
        disabledAttribute = "disabled";
    }
}
<h1>Delete this file for production!</h1>
<form method="post" action="">
    <input type="submit" value="DB fill" @disabledAttribute />
    @if (disabledAttribute != "")
    {
        <b><a href="@Href("~/")">Go home!</a></b>
    }
</form>
